package com.neuralnoise.hibernate.geo;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.MappedSuperclass;

@MappedSuperclass
public abstract class AbstractGeoLocation implements java.io.Serializable {

	private static final long serialVersionUID = 638912669989054648L;

	private GeoLocationId id;
	
	private String name;
	private Double altitude;
	private Double latitude;
	private Double longitude;
	
	public AbstractGeoLocation() { }
	
	public AbstractGeoLocation(GeoLocationId id) {
		this();
		this.id = id;
	}
	
	public AbstractGeoLocation(GeoLocationId id,
			String name, Double altitude, Double latitude, Double longitude) {
		this(id);
		this.name = name;
		this.altitude = altitude;
		this.latitude = latitude;
		this.longitude = longitude;
	}
	
	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "address", column = @Column(name = "address", nullable = false, length = 64)),
			@AttributeOverride(name = "language", column = @Column(name = "language", nullable = false, length = 8)) })
	public GeoLocationId getId() {
		return id;
	}

	public void setId(GeoLocationId id) {
		this.id = id;
	}

	@Column(name = "name", nullable = false, length = 256)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "altitude", nullable = false)
	public Double getAltitude() {
		return altitude;
	}

	public void setAltitude(Double altitude) {
		this.altitude = altitude;
	}

	@Column(name = "latitude", nullable = false)
	public Double getLatitude() {
		return latitude;
	}

	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}

	@Column(name = "longitude", nullable = false)
	public Double getLongitude() {
		return longitude;
	}

	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}
}
